# Maintainer: Brett Cornwall <ainola@archlinux.org>
# Contributor: Gennadiy Mykhailiuta
# Contributor: Westofer Raymond

pkgname=ytfzf
pkgver=2.5.5
pkgrel=1
pkgdesc="A POSIX script to find and watch youtube videos from the terminal"
arch=('any')
url="https://github.com/pystardust/ytfzf"
license=('GPL3')
depends=('jq' 'curl')
makedepends=('gzip')
optdepends=(
    'dmenu: Search prompts and results via dmenu'
    'mpv: Default media player'
    'fzf: The default menu selection screen'
    'ueberzug: The default thumbnails image previewer'
    'yt-dlp: For downloading content'
)
source=("$pkgname-$pkgver.tar.gz::https://github.com/pystardust/ytfzf/archive/refs/tags/v$pkgver.tar.gz")
sha256sums=('c124636e6262a343a4574187eca2f422c8f1f210fafd5b1312bb4d42fcc0fbb2')

package() {
    cd "$pkgname-$pkgver"
    install -Dm0755 ytfzf -t "$pkgdir/usr/bin/"

    install -dm0755 "$pkgdir/usr/share/$pkgname/addons"
    cp -r addons/* "$pkgdir/usr/share/$pkgname/addons"
    find "$pkgdir/usr/share/$pkgname/addons" -exec chmod 0755 {} +

    install -Dm644 README.md -t "$pkgdir/usr/share/doc/$pkgname"
    cd docs
    install -dm0755 "$pkgdir"/usr/share/man/man{1,5}
    gzip < "man/$pkgname.1" > "$pkgdir/usr/share/man/man1/$pkgname.1.gz"
    gzip < "man/$pkgname.5" > "$pkgdir/usr/share/man/man5/$pkgname.5.gz"
    install -Dm0644 conf.sh -t "$pkgdir/usr/share/doc/$pkgname"
    install -Dm0644 subscriptions -t "$pkgdir/usr/share/doc/$pkgname"
}
